<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all">
</head>
<body>
<div class="layui-container" style="width: 700px;height: 600px;margin-top: 0px;padding-top: 60px;">

    <div style="margin-left: 460px; width: 200px;">
<!--        欢迎回来！<a href="/order" th:text="${session.name}"></a><a href="/account/logout">&nbsp;&nbsp;&nbsp;<button class="layui-btn layui-btn-warm layui-btn-radius">退出</button></a>-->
        欢迎回来！<a th:text="${session.name}"></a>
        <a href="/order/orderTable">&nbsp;&nbsp;&nbsp;<button class="layui-btn layui-btn-warm layui-btn-radius">订单</button></a>
        <a href="/account/logout">&nbsp;&nbsp;&nbsp;<button class="layui-btn layui-btn-warm layui-btn-radius">退出</button></a>
<!--        用于测试session中是否存有应有的属性-->
        <a href="/test">&nbsp;&nbsp;&nbsp;<button class="layui-btn layui-btn-warm layui-btn-radius">测试</button></a>
    </div>

    <table class="layui-hide" id="test" lay-filter="test"></table>
    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-xs" lay-event="order">订购</a>
    </script>
    <script th:src="@{/layui/layui.js}" charset="utf-8"></script>
    <script>
        layui.use('table', function(){
            var table = layui.table;

            table.render({
                elem: '#test'
                ,url:'/menu/queryMenuList'
                ,title: '菜单列表'
                ,cols: [
                    [
                        {field:'id', width:100, title: '编号', sort: true}
                        ,{field:'name', width:100, title: '菜品'}
                        ,{field:'price', width:100, title: '单价'}
                        ,{field:'description', width:100, title: '分类'}
                    //@yucs 20201/8/26    TODO : 图片展示
                    //     ,{field: 'image', width: 200,title: '图片',align: 'center',sort:false,templet:function (data){
                    //         return '<div οnclick="photograph(this)"><img src='+data.orderItemList[0].menu.imgUrl+'></div>'
                    //     }
                    // }
                        ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:70}
                    ]
                ]
                ,page: true
            });

            //监听行工具事件
            table.on('tool(test)', function(obj){
                var data = obj.data;
                if(obj.event === 'order'){
                    window.location.href="/order/save/"+data.id;
                }
            });
        });
    </script>

</div>
<script>
    //二级菜单联动
    layui.use('element', function(){
        var element = layui.element;

    });
</script>
</body>
</html>